import java.util.HashMap;
import java.util.Map;

public class StrangeElevator {
	private static final int MOD = 1000000007;

	Map<Long, Long> composite = new HashMap<Long, Long>();
	Map<Long, Long> simple = new HashMap<Long, Long>();

	public int theCount(int H, int N) {
		if (H % N != 0)
			return 0;
		return (int) ((countComposite(H, N) + countSimple(H, N)) % MOD);
	}

	private long countSimple(int H, int N) {
		long key = (((long)H) << 32) + N;
		if (simple.containsKey(key))
			return simple.get(key);
		if (N == 1)
			return 1;
		long answer = 0;
		int ratio = H / N;
		for (int i = 2; i * i <= ratio; i++) {
			if (ratio % i == 0) {
				answer += countComposite(H / i, N);
				if (ratio / i != i)
					answer += countComposite(H / (ratio / i), N);
			}
		}
		if (ratio != 1)
			answer += countComposite(N, N);
		simple.put(key, answer %= MOD);
		return answer;
	}

	private long countComposite(int H, int N) {
		long key = (((long)H) << 32) + N;
		if (composite.containsKey(key))
			return composite.get(key);
		long answer = 0;
		for (int i = 2; i * i <= N; i++) {
			if (N % i == 0) {
				answer += countSimple(H / i, N / i);
				if (N / i != i)
					answer += countSimple(H / (N / i), i);
			}
		}
		if (N != 1)
			answer += countSimple(H / N, 1);
		composite.put(key, answer %= MOD);
		return answer;
	}

	// BEGIN CUT HERE
	public static void main(String[] args) {
		if (args.length == 0) {
			StrangeElevatorHarness.run_test(-1);
		} else {
			for (int i=0; i<args.length; ++i)
				StrangeElevatorHarness.run_test(Integer.valueOf(args[i]));
		}
	}
// END CUT HERE
}

// BEGIN CUT HERE
class StrangeElevatorHarness {
	public static void run_test(int casenum) {
		if (casenum != -1) {
			if (runTestCase(casenum) == -1)
				System.err.println("Illegal input! Test case " + casenum + " does not exist.");
			return;
		}
		
		int correct = 0, total = 0;
		for (int i=0;; ++i) {
			int x = runTestCase(i);
			if (x == -1) {
				if (i >= 100) break;
				continue;
			}
			correct += x;
			++total;
		}
		
		if (total == 0) {
			System.err.println("No test cases run.");
		} else if (correct < total) {
			System.err.println("Some cases FAILED (passed " + correct + " of " + total + ").");
		} else {
			System.err.println("All " + total + " tests passed!");
		}
	}
	
	static boolean compareOutput(int expected, int result) { return expected == result; }
	static String formatResult(int res) {
		return String.format("%d", res);
	}
	
	static int verifyCase(int casenum, int expected, int received) { 
		System.err.print("Example " + casenum + "... ");
		if (compareOutput(expected, received)) {
			System.err.println("PASSED");
			return 1;
		} else {
			System.err.println("FAILED");
			System.err.println("    Expected: " + formatResult(expected)); 
			System.err.println("    Received: " + formatResult(received)); 
			return 0;
		}
	}

	static int runTestCase(int casenum) {
		switch(casenum) {
		case 0: {
			int H                     = 58;
			int N                     = 2;
			int expected__            = 2;

			return verifyCase(casenum, expected__, new StrangeElevator().theCount(H, N));
		}
		case 1: {
			int H                     = 1;
			int N                     = 1;
			int expected__            = 1;

			return verifyCase(casenum, expected__, new StrangeElevator().theCount(H, N));
		}
		case 2: {
			int H                     = 9;
			int N                     = 3;
			int expected__            = 2;

			return verifyCase(casenum, expected__, new StrangeElevator().theCount(H, N));
		}
		case 3: {
			int H                     = 120;
			int N                     = 12;
			int expected__            = 30;

			return verifyCase(casenum, expected__, new StrangeElevator().theCount(H, N));
		}
		case 4: {
			int H                     = 58585858;
			int N                     = 495;
			int expected__            = 0;

			return verifyCase(casenum, expected__, new StrangeElevator().theCount(H, N));
		}

		// custom cases

/*      case 5: {
			int H                     = ;
			int N                     = ;
			int expected__            = ;

			return verifyCase(casenum, expected__, new StrangeElevator().theCount(H, N));
		}*/
/*      case 6: {
			int H                     = ;
			int N                     = ;
			int expected__            = ;

			return verifyCase(casenum, expected__, new StrangeElevator().theCount(H, N));
		}*/
/*      case 7: {
			int H                     = ;
			int N                     = ;
			int expected__            = ;

			return verifyCase(casenum, expected__, new StrangeElevator().theCount(H, N));
		}*/
		default:
			return -1;
		}
	}
}

// END CUT HERE
